package com.wfh.inner;

import com.wfh.common.ErrorCode;
import com.wfh.constant.UserConstant;
import com.wfh.exception.BusinessException;
import com.wfh.model.entity.User;
import com.wfh.model.vo.UserVO;
import jakarta.servlet.http.HttpServletRequest;


import java.io.Serializable;
import java.util.Collection;
import java.util.List;

/**
 * @Title: InnerUserService
 * @Author wangfenghuan
 * @Package com.wfh.inner
 * @Date 2025/8/28 10:55
 * @description:
 */
public interface InnerUserService {

    /**
     * 根据id集合获取用户集合
     * @param ids
     * @return
     */
    List<User> listByIds(Collection<? extends Serializable> ids);

    /**
     * 根据id获取用户
     * @param id
     * @return
     */
    User getById(Serializable id);

    /**
     * 获取用户vo对象
     * @param user
     * @return
     */
    UserVO getUserVO(User user);

    /**
     * 获取当前登录用户
     * @param request
     * @return
     */
    static User getLoginUser(HttpServletRequest request){
        User user = (User) request.getSession().getAttribute(UserConstant.USER_LOGIN_STATE);
        if (user == null || user.getId() == null){
            throw new BusinessException(ErrorCode.NOT_LOGIN_ERROR);
        }
        return user;
    }
}
